import glob
import pandas as pd

# 1.要是合并的表格为excel 把后面的.csv后缀改成.xlsx

inputfile = r'C:\Users\xys3817\Desktop\biaoge\hebing6666666\*.csv'
print(inputfile)
outputfile = r'C:\Users\xys3817\Desktop\biaoge\hebing6666666\888990.csv'
csv_list = glob.glob(inputfile)
filepath = csv_list[0]
# 2.在把下面带CSV的注释或者删除把下面带excel的注释去掉就欧克了
df = pd.read_csv(filepath, encoding="gbk", low_memory=False)

# df = pd.read_excel(filepath, encoding="gbk", low_memory=False)

df = df.to_csv(outputfile, encoding="gbk", index=False)
# df = df.to_excel(outputfile, encoding="gbk", index=False)

for i in range(1, len(csv_list)):
    filepath = csv_list[i]
    df = pd.read_csv(filepath, encoding="gbk", low_memory=False)
    # df = pd.read_excel(filepath, encoding="gbk", low_memory=False)

    df = df.to_csv(outputfile, encoding="gbk", index=False, header=False, mode='a+')

    # df = df.to_excel(outputfile, encoding="gbk", index=False, header=False, mode='a+')

print("合并成功！！！")